package cn.imnaer.service.rest.push.impl;

import java.util.ArrayList;
import java.util.List;

import cn.imnaer.service.persistence.model.PushMessage;
import cn.imnaer.service.rest.view.model.FriendCircleMessage;
import cn.imnaer.service.rest.view.model.Response;
import cn.imnaer.service.rest.view.model.SimpleResponse;
import cn.imnaer.service.rpc.push.impl.PushComponentRpcApiImpl;
import cn.shiyu.service.rest.push.PushComponentRestApi;

public class PushComponentRestApiImpl implements PushComponentRestApi {


    private final PushComponentRpcApiImpl pushComponentRpcApi = new PushComponentRpcApiImpl();

    @Override
    public String sharePhotoPushMessageList(String userId) {
        List<PushMessage> record = pushComponentRpcApi.getPushMessages(userId);
        List<FriendCircleMessage> list = new ArrayList<>(record.size());
        for (PushMessage pushMessage : record) {
            FriendCircleMessage item = FriendCircleMessage.parse(pushMessage);
            list.add(item);
        }
        return new Response().success(list);
    }

    @Override
    public String sharePhotoPushMessageCount(String userId) {
        int count = pushComponentRpcApi.getPushMessagesCount(userId);
        return new SimpleResponse().success(count);
    }

}
